#!/bin/sh

/bin/echo -n "start:";date +%Y-%m-%d:%H:%I:%S
# shellcheck disable=SC2006
pid=`ps -eo etime,pid,command | grep -v grep | grep -v run.sh | grep '\./proxy_dns_server' | awk '{print $2}'`
if [[ $1 == "kill" ]];then
  if [[ $pid != "" ]];then
    kill -9 $pid
    echo "kill proxy_dns_server."
  else
    echo "no need kill proxy_dns_server."
  fi
  exit
fi
if [[ $pid == "" ]];then
    cd /Users/kso/git/dns_server
    ./proxy_dns_server >> /tmp/proxy_dns_server.log 2>&1 &
    echo "start proxy_dns_server."
else
	ps -eo etime,pid,command | grep -v grep | grep -v run.sh | grep '\./proxy_dns_server'
    echo "proxy_dns_server is running:$pid"
fi

/bin/echo -n "finish:";date +%Y-%m-%d:%H:%I:%S

